package gameUtils;

import games.RankingEntry;

import java.util.Comparator;

public class RankingEntryComparator implements Comparator<RankingEntry> {

	@Override
	public int compare(RankingEntry rankingEntry1, RankingEntry rankingEntry2) {
		if(rankingEntry1.getMapId() != rankingEntry2.getMapId()) 
			return rankingEntry2.getMapId() - rankingEntry1.getMapId();
		
		if(rankingEntry1.getInvadersDestroyedInvaders() != rankingEntry2.getInvadersDestroyedInvaders()) 
			return rankingEntry2.getInvadersDestroyedInvaders() - rankingEntry1.getInvadersDestroyedInvaders();
		
		if(rankingEntry1.getBudget() != rankingEntry2.getBudget()) 
			return rankingEntry2.getBudget() - rankingEntry1.getBudget();
		
		return 0;
	}

}
